package org.jeecg.modules.online.config.model;

import org.jeecg.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component("dataBaseConfig")
@ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
public class DataBaseConfig {
	@Autowired
	private DmDataBaseConfig dmDataBaseConfig;
	
    private String url;
	private String username;
	private String password;
	private String driverClassName;
	private Druid druid;
	public Druid getDruid() {
		if(druid==null){
			return dmDataBaseConfig.getDruid();
		}
		return druid;
	}
	public void setDruid(Druid druid) {
		this.druid = druid;
	}
	public String getUrl() {
		return oConvertUtils.getString(url,dmDataBaseConfig.getUrl());
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUsername() {
		return oConvertUtils.getString(username,dmDataBaseConfig.getUsername());
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return oConvertUtils.getString(password,dmDataBaseConfig.getPassword());
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getDriverClassName() {
		return oConvertUtils.getString(driverClassName,dmDataBaseConfig.getDriverClassName());
	}
	public void setDriverClassName(String driverClassName) {
		this.driverClassName = driverClassName;
	}

	/**
	 * 正常情况下用不到此方法,用于online多数据源配置
	 * @param dmDataBaseConfig
	 */
	public void setDmDataBaseConfig(DmDataBaseConfig dmDataBaseConfig) {
		this.dmDataBaseConfig = dmDataBaseConfig;
	}
}


